<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="zh-cn">
    <head>
        <!-- Bootstrap -->
        <include file="Include/css" />
        <title>中经汇通-首页</title>
        <link href="__STATICS__/css/admin/index.css" rel="stylesheet">
        <link href="__STATICS__/css/sweet-alert.css" rel="stylesheet">
        <script type="text/javascript" src="__STATICS__/js/sweet-alert.min.js"></script>

    </head>
    <body>
        <include file="Include/nav_top" />
        <div class="container clearfix" id="left_menu_wraper" >
            <include  file="Include/menu_left" />
            <div id="right-content">
                <div id="right-content-inner">
                    <ul class="breadcrumb">
                        <span>您的位置：</span>
                        <li><a href="{:U('CNEPAdmin/Index/index')}">首页</a> </li>
                        <li class="">广告管理</li>
                        <li class="active">推送图片列表</li>
                    </ul>

                    <p>
                        <button id="add_look" class="btn btn-orange" type="button" >
                            添加图片
                        </button>
                    </p>

                    <div role="tabpanel">

                        <table class="table table-striped table_qrcode table-hover">
                            <!--<caption>标题</caption>-->
                            <thead>
                                <tr class="border">
                                    <th>编号</th>
                                    <th>图片</th>
                                    <th>显示顺序</th>
                                    <th>添加时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <volist name="list" id="vo">
                                    <tr class="qr_tar">
                                        <td>{$i+$num}</td>
                                        <td><img src="{$vo.thumbPath}" width="200px" height="200px" ></img>
                                        </td>
                                        <td>{$vo.ind}</td>
                                        <td>{$vo['addTime'] | date="Y/m/d H:i:s",###}</td>
                                        <td data-id="{$vo.picID}"
                                            data-ind="{$vo.ind}"
                                            data-picPath="{$vo.picPath}" 
                                            data-thumbPath="{$vo.thumbPath}"
                                            data-addTime="{$vo['addTime'] | date="Y/m/d H:i:s",###}" 
                                            ><a href="javascript:void(0)" class="edit_look" >编辑</a> 
                                            /
                                            <a href="javascript:void(0)" class="tar_delete"  >删除</a> </td>
                                    </tr>
                                </volist>
                            </tbody>
                        </table>

                        <div class="clearfix s_page pull-right">
                            {$page}
                        </div>

                    </div>

                </div>

            </div>
        </div>

        <!-- Modal -->
<div class="modal fade bs-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel"> </h4>
      </div>
      <div class="modal-body">
          
            <div class="row clearfix">
                    <div class="col-md-12 margin10">
                            <div class="col-md-2 text_right form_bar">
                                    播放顺序：
                            </div>
                            <div class="col-md-6">
                                <input id="ind" type="text" class="form-control"/>
                            </div>
                    </div>
                    <div class="col-md-12 margin10" >
                        <div class="col-md-2 text_right form_bar">
                                图片：
                        </div>
                        <div class="col-md-4">
                            <div class=" padding0 margin10">
                                <div class="upload_wraper dash" >
                                    <div class="logo_wraper ">
                                        <img id="pic"  src="" 
                                             class="width100 img-rounded" alt="">
                                        <input type="file" class="input_file" id="fileupload" name="file" value="" data-url="" multiple="">
                                    </div>
                                </div>
                            </div>
                        </div>                                                                                              

                    </div>

            </div>

          <input type="hidden" id="picPath" value="" />
          <input type="hidden" id="thumbPath" value="" />
          <input type="hidden" id="picID" value="" />
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary" id="save" >保存</button>
      </div>
    </div>
  </div>
</div>

        <include file="Include/script" />
        <script src="__STATICS__/js/jquery.ui.widget.js"></script>
        <script src="__STATICS__/js/jquery.iframe-transport.js"></script>
        <script src="__STATICS__/js/jquery.fileupload.js"></script>
        <script src="__STATICS__/js/jquery-form.js"></script>
        
        <script src="__STATICS__/js/admin/hzAjax.js" type="text/javascript"></script>
        <script type="text/javascript" src="__STATICS__/js/upload_base.js"></script>
        
        <script>
            var isReload = false; // 标识弹出框关闭之后是否刷新页面
            var statics_url = "__STATICS__";
            var headImgUrl = "{:U('CNEPAdmin/Upload/uploadImg/pathType/2')}";
            var img_url  = "__STATICS__/images";
            
            /*菜单展开及高亮*/
            $(function () {
                $('.slideImg').addClass('open');
                $('#slideImg2').addClass('active');
                
                upload_img_1(headImgUrl,'fileupload',onUpload);// 上传图片
                
                function onUpload(rsp) {
                    if(rsp.result > 0) {
                        $("#pic").attr("src", rsp.path);
                        $("#picPath").val(rsp.path);
                        $("#thumbPath").val(rsp.thumb);
                    } else {
                        swal("系统错误","","error");
                    }
                }
                
                 /*弹出框隐藏后*/
                $('#myModal').on('hidden.bs.modal', function (e) {
                     reset_display();
                })
                
                $("#add_look").on("click",function() {
                    $("#myModalLabel").html("添加图片");
                    $('#myModal').modal(); // 跳出弹窗
                });
                $(".edit_look").on("click",function() {
                      var self = $(this).closest('td');
                      
                       $("#picPath").val(self.attr("data-picPath"));
                       $("#thumbPath").val(self.attr("data-thumbPath"));
                       $("#picID").val(self.attr("data-id"));
                       $("#ind").val(self.attr("data-ind"));
                       $("#pic").attr("src",self.attr("data-picPath"));
                                             
                       $("#myModalLabel").html("编辑");
                       $('#myModal').modal(); // 跳出弹窗
                    	                  
                });
                
                /*保存*/
                $("#save").on("click",function() {
                    
                    var picID=$("#picID").val();
                    var data= {};
                    data.picPath=$("#picPath").val();
                    data.thumbPath=$("#thumbPath").val();
                    data.picID = picID;
                    data.ind=$("#ind").val();
                   
                    if(data.picPath==""){
                        swal("请上传图片","","warnning");
                        return false;
                    }
                    else if(parseInt(data.ind) == "undefined" || data.ind == ''){
                    	swal("请输入正确的顺序","","warnning");
                        return false;
                    }
                    
                    ajax_go(data,"{:U('CNEPAdmin/Pic/savePic')}",true);
                });
                                       
                
                $(".tar_delete").on("click", function () {
                    var self = $(this);
                    swal({   title: "您确定吗?",
                                text: "您将删除该图片！",
                                type: "warning",
                                showCancelButton: true,
                                confirmButtonColor: "#DD6B55",
                                confirmButtonText: "是的，删除",
                                cancelButtonText: "放弃",
                                closeOnConfirm: false
                            },
                            function (isConfirm) {
                                if (isConfirm) {
                                    var ajaxData = {};
                                    ajaxData.picID = self.parent("td").attr("data-id");
                                    ajax_go(ajaxData ,'{:U("CNEPAdmin/Pic/deletePic")}',true);
                                }

                            });


                });
                
                
            });
                        
            /*清空弹出框内容*/
            function reset_display()
            {
                if(isReload) {
                    window.location.reload();
                }
                
                $("#picID").val("");
                $("#picPath").val("");
                $("#thumbPath").val("");
                $("#ind").val("");
                $("#pic").attr("src",'');

            }
                        
        </script>
    </body>
</html>